<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>9.after和before追加元素样式使用</title>
  <link rel="stylesheet" href="1.css">
  <style>

    h2 {
      position: relative;
      cursor: pointer;
    }
    h2:hover:before {
      content: attr(data-title);
      color:green;
      position: absolute;
      background: #555;
      color: #fff;
      left: 10px;
      background-origin: -30px;
      padding: 5px;
      border: solid1px #ddd;
    }
  </style>
  </head>
  
  <body>
  
    <h2 data-title="houdunre.cn">后盾人</h2>
  </body>
  
  </html>